// run: $exec < input > out
#include <iostream>
#include <string>
#include <cstring>
#include <queue>
#include <set>

#define _DEBUG

struct path { int x, y, state; };
struct pair { int honest, liar, state; };

int const maxn = 606 * 2;
int const maxp = 303;
int parent[maxn], rank[maxn];
path from[maxp][maxp];
bool inque[maxp][maxp];
int count[maxp][maxp];
bool vis[maxn];
int n, m, p1, p2; // p1: honest, p2: liar

int output[maxn];
pair count_pair[maxn]; // honest, liar
int tot;

void init()
{
	n = p1 + p2;
	for (int i = 1; i <= 2*n; i++) parent[i] = i, rank[i] = 1;
}

int get_parent(int u)
{
	return u == parent[u] ? u : (parent[u] = get_parent(parent[u]));
}

void set_union(int u, int v)
{
	int tu = get_parent(u);
	int tv = get_parent(v);
	if (tu != tv) {
		if (rank[tu] < rank[tv]) parent[tu] = tv;
		else {
			parent[tv] = tu;
			if (rank[tu] == rank[tv]) rank[tu]++;
		}
	}
}

void get_all_pair()
{
	tot = 0;
	std::memset(vis, 0, sizeof(vis));

	for (int i = 1; i <= n; i++) {
		if (vis[i]) continue;
		vis[i] = true;
		pair tmp; tmp.honest = 0; tmp.liar = 0;
		for (int j = 1; j <= n; j++)
			if (get_parent(j) == get_parent(i)) {
				tmp.honest++;
				vis[j] = true;
			}
		for (int j = n + 1; j <= 2 * n; j++)
			if (get_parent(j) == get_parent(i)) {
				tmp.liar++;
				vis[j - n] = true;
			}
		tmp.state = i;
		count_pair[tot++] = tmp;
	}

#ifdef __DEBUG
	std::cout << "tot = " << tot << " --------\n";
	for (int i = 0; i < tot; i++)
		std::cout << count_pair[i].honest << ' ' << count_pair[i].liar << '\n';
	std::cout << "--------\n";
#endif
}

int bfs()
{
	std::queue<pair> q;
	std::queue<pair> tq;
	pair first; first.honest = 0; first.liar = 0; first.state = 0;
	q.push(first);
	std::memset(inque, 0, sizeof(inque));
	std::memset(count, 0, sizeof(count));
	count[0][0] = 1;
	for (int i = 0; i < tot; i++) {
#ifdef __DEBUG
		std::cout << "i = " << i << ' ' << q.size() << '\n';
#endif
		while (!q.empty()) {
			pair now = q.front(); q.pop();
			pair tmp;
			tmp.honest = now.honest + count_pair[i].honest;
			tmp.liar = now.liar + count_pair[i].liar;
			tmp.state = count_pair[i].state;
			count[tmp.honest][tmp.liar] += count[now.honest][now.liar];
			if (count[tmp.honest][tmp.liar] > 1) count[tmp.honest][tmp.liar] = 2;
			from[tmp.honest][tmp.liar].x = now.honest;
			from[tmp.honest][tmp.liar].y = now.liar;
			from[tmp.honest][tmp.liar].state = tmp.state;

#ifdef __DEBUG
			std::cout << tmp.honest << ' ' << tmp.liar << '\n';
#endif

			if (!inque[tmp.honest][tmp.liar]) {
				tq.push(tmp);
				inque[tmp.honest][tmp.liar] = true;
			}

			tmp.honest = now.honest + count_pair[i].liar;
			tmp.liar = now.liar + count_pair[i].honest;
			tmp.state = count_pair[i].state + n;
			count[tmp.honest][tmp.liar] += count[now.honest][now.liar];
			if (count[tmp.honest][tmp.liar] > 1) count[tmp.honest][tmp.liar] = 2;
			from[tmp.honest][tmp.liar].x = now.honest;
			from[tmp.honest][tmp.liar].y = now.liar;
			from[tmp.honest][tmp.liar].state = tmp.state;

#ifdef __DEBUG
			std::cout << tmp.honest << ' ' << tmp.liar << '\n';
#endif

			if (!inque[tmp.honest][tmp.liar]) {
				tq.push(tmp);
				inque[tmp.honest][tmp.liar] = true;
			}
		}
		while (!tq.empty()) {
			q.push(tq.front());
			inque[tq.front().honest][tq.front().liar] = false;
			tq.pop();
		}
	}
	return count[p1][p2];
}

void print()
{
	std::set<int> index;
	for (int px = p1, py = p2; px || py; ) {
		index.insert(get_parent(from[px][py].state));

#ifdef __DEBUG
			std::cout << "==> " << from[px][py].state << '\n';
#endif

		int x = from[px][py].x, y = from[px][py].y;
		px = x; py = y;
	}
	for (int i = 1; i <= n; i++)
		if (index.find(get_parent(i)) != index.end())
			std::cout << i << '\n';
	std::cout << "end\n";
}

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> m >> p1 >> p2 && (m || p1 || p2)) {
		init();

		std::string s;
		for (int i = 0, x, y; i < m; i++) {
			std::cin >> x >> y >> s;
			if (s[0] == 'y') {
				set_union(x, y);
				set_union(x + n, y + n);
			} else {
				set_union(x, y + n);
				set_union(x + n, y);
			}
		}
		get_all_pair();

		int tmp = bfs();
		if (tmp > 1 || !tmp)
			std::cout << "no\n";
		else {
			print();
		}
	}
}

